Copyright ã1995 by NeXT Computer, Inc.  All Rights Reserved.

NILoginPanel

Inherits From:	Panel : Window : Responder : Object

Declared In:	nikit/NILoginPanel.h

Class Description

NILoginPanel provides a means of authentication for accessing a NetInfo domain.  It can be used to determine authorization to run an application, as with HostManager and UserManager, or to determine if a user can modify a domain, as with NetInfoManager and NFSManager. The panel includes text fields for the user name and password, an icon, and text for instructions to the user.

Instance Variables

id panel;

id userField;

id passwordField;

id  instructionText;

BOOL validLogin;

BOOL loginSuccess;

int bootMode;

char currentUser[16];

char currentPassword[16];

id iconButton;

panel	Panel object.

userField	Text field for user account name.

passwordField	Text field for password.

instructionText	Text for instructions to the user.

validLogin	Indicates if an authentication attempt was successful.  

loginSuccess	Currently means the same as validLogin.

bootMode	Indicates whether the delegate should perform authentication.

currentUser	Name of current user.

currentPassword	Password of current user.

iconButton	Icon to display in panel.

Method Types

Creating an NILoginPanel object
+ new

Running the panel	- runModal:inDomain:
- runModal:inDomain:withUser:withInstruction: allowChange:
- runModalWithValidation:inDomain: withUser:withInstruction:allowChange:

Target and action methods	- ok:
- cancel:

Getting data	- isValidLogin:
- getPassword:
- getUser:

Class Methods

new

+ new

Creates, if necessary, and returns the shared instance of NILoginPanel.

Instance Methods

cancel:

- cancel:sender

Sent automatically when the Cancel button is clicked.  Returns self.

getPassword:

- (const char *)getPassword:sender

Returns the password entered into the password text field.  The password is correct only if this method is invoked from panel:authenticateUser:withPassword:inDomain:. Otherwise, returns NULL.

getUser:

- (const char *)getUser:sender

Returns the account name entered into the user text field.

isValidLogin:

- (BOOL)isValidLogin:sender

Returns TRUE if the account name and password represent a successful authentication for the domain; otherwise, returns FALSE.

ok:

- ok:sender

Target method for the Login button.  Zeroes the password value, for security reasons.  Returns self.

runModal:inDomain:

- (BOOL)runModal:sender inDomain:(void *)domainID

Begins a modal event loop for the panel. Runs the panel for the domain indicated by the NetInfo handle domainID.  You can obtain the NetInfo handle with the domainHandle method of the NIDomain class.  The user root will be used as the default user.  Returns TRUE if the user logged in successfully; otherwise, returns FALSE.

See also:  - runModal:inDomain:withUser:withInstruction:allowChange:, - runModalWithValidation:inDomain:withUser:withInstruction:allowChange

runModal:inDomain:withUser:withInstruction:allowChange:

- (BOOL)runModal:sender 
inDomain:(void *)domainID 
withUser:(const char *)userName 
withInstruction:(const char *)warning 
allowChange:(BOOL)flag

Begins a modal event loop for the panel for the specified domain and user. The string in warning will be displayed in the panel as instructions to the user. If flag is TRUE, the user won't be allowed to change the user name in the text field.  Returns TRUE if the user logs in successfully; otherwise, returns FALSE.

runModalWithValidation:inDomain:withUser:withInstruction:
allowChange:

- (BOOL)runModalWithValidation:sender 
inDomain:(void *)domainID 
withUser:(const char *)userName 
withInstruction:(const char *)warning 
allowChange:(BOOL)enableUser

Same as runModal:inDomain:withUser:withInstruction:allowChange:, except that the user will be authenticated by the delegate instead of by the ni_setuser() and ni_setpassword() functions.  Returns TRUE if the user logged in successfully; otherwise, returns FALSE.

See also:  panel:authenticateUser:withPassword:inDomain: (delegate method)

Methods Implemented by the Delegate

panel:authenticateUser:withPassword:inDomain:

- (BOOL)panel:thePanel 
authenticateUser:(const char *)userName 
withPassword:(const char *)password 
inDomain:(const void *)domain

Sent by runModalWithValidation:inDomain:withUser:withInstruction: allowChange:.  Should determine whether the combination of userName, password, and domain is valid.  Returns TRUE if the user should be authenticated, FALSE otherwise.